package com.ruoyi.business.controller;

import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.VideoCategory;
import com.ruoyi.business.service.IVideoCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频分类Controller
 * 
 * @author lcz
 * @date 2025-01-19
 */
@Api(tags = "视频分类相关接口")
@RestController
@RequestMapping("/business/videoCategory")
public class VideoCategoryController extends BaseController
{
    @Autowired
    private IVideoCategoryService videoCategoryService;

    /**
     * 查询视频分类列表
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:videoCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoCategory videoCategory)
    {
        startPage();
        List<VideoCategory> list = videoCategoryService.selectVideoCategoryList(videoCategory);
        return getDataTable(list);
    }

    /**
     * 导出视频分类列表
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:videoCategory:export')")
    @Log(title = "视频分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoCategory videoCategory)
    {
        List<VideoCategory> list = videoCategoryService.selectVideoCategoryList(videoCategory);
        ExcelUtil<VideoCategory> util = new ExcelUtil<VideoCategory>(VideoCategory.class);
        util.exportExcel(response, list, "视频分类数据");
    }

    /**
     * 获取视频分类详细信息
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:videoCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(videoCategoryService.selectVideoCategoryById(id));
    }

    /**
     * 新增视频分类
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:videoCategory:add')")
    @Log(title = "视频分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoCategory videoCategory)
    {
        return toAjax(videoCategoryService.insertVideoCategory(videoCategory));
    }

    /**
     * 修改视频分类
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:videoCategory:edit')")
    @Log(title = "视频分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoCategory videoCategory)
    {
        return toAjax(videoCategoryService.updateVideoCategory(videoCategory));
    }

    /**
     * 删除视频分类
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:videoCategory:remove')")
    @Log(title = "视频分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoCategoryService.deleteVideoCategoryByIds(ids));
    }

    /** 前端接口 ***************************************************************************************************/
    /** 前端接口 ***************************************************************************************************/
    /** 前端接口 ***************************************************************************************************/

    /**
     * 查询视频分类列表
     * 接口路径：/videoCategory/front/list
     */
    @GetMapping("/front/list")
    @ApiOperation("视频分类列表")
    public R<List<VideoCategory>> frontList(VideoCategory videoCategory)
    {
        List<VideoCategory> list = videoCategoryService.selectVideoCategoryList(videoCategory);
        return R.ok(list);
    }

//    /**
//     * 获取视频分类详细信息
//     * 接口路径：/videoCategory/front/info
//     */
//    @ApiOperation("前台获取视频分类详细信息")
//    @GetMapping(value = "/front/info")
//    public R<VideoCategory> frontInfo(@RequestParam("id") Long id)
//    {
//        return R.ok(videoCategoryService.selectVideoCategoryById(id));
//    }
//
//    /**
//     * 新增视频分类
//     * 接口路径：/videoCategory/front/add
//     */
//    @ApiOperation("前台新增视频分类")
//    @PostMapping("/front/add")
//    public AjaxResult frontAdd(@RequestBody VideoCategory videoCategory)
//    {
//        return toAjax(videoCategoryService.insertVideoCategory(videoCategory));
//    }
//
//    /**
//     * 修改视频分类
//     * 接口路径：/videoCategory/front/edit
//     */
//    @ApiOperation("前台修改视频分类")
//    @PostMapping("/front/edit")
//    public AjaxResult frontEdit(@RequestBody VideoCategory videoCategory)
//    {
//        return toAjax(videoCategoryService.updateVideoCategory(videoCategory));
//    }
//
//    /**
//     * 删除视频分类
//     * 接口路径：/videoCategory/front/delete
//     */
//    @ApiOperation("前台删除视频分类")
//    @GetMapping("/front/delete")
//    public AjaxResult frontRemove(@RequestParam Long[] ids)
//    {
//        return toAjax(videoCategoryService.deleteVideoCategoryByIds(ids));
//    }
}
